package com.aspose.cells;

class zaww extends zawv {
   private int l;
   private int m;
   private boolean n;
   private boolean o;
   private boolean p;
   private boolean q;
   private int r;
   private int s;

   public zaww(zahn var1, zahn var2, zagl var3, zaay var4, int var5, int var6) {
      super(var1, var2, var3, var4);
      this.l = var5;
      this.m = var6;
      if (var1.m()) {
         this.n = true;
         this.o = false;
         this.p = false;
         this.q = var2.n();
      } else {
         this.n = false;
         if (var1.n()) {
            this.o = true;
            this.q = false;
            this.p = var2.m();
         } else {
            this.o = false;
            if (var2.m()) {
               this.p = true;
               this.q = false;
            } else {
               this.p = false;
               this.q = var2.n();
            }
         }
      }

   }

   zaww(zaww var1, zaay var2) {
      super(var1.a.b(var2), var1.b.b(var2), (zagl)var1.c.a(var2), var2);
      this.e = var1.e;
      this.l = var1.l;
      this.m = var1.m;
      this.n = var1.n;
      this.p = var1.p;
      this.o = var1.o;
      this.q = var1.q;
   }

   public zahn b(zaay var1) {
      return new zaww(this, var1);
   }

   public boolean b(int var1, int var2) {
      if (var1 == this.r && var2 == this.s) {
         return true;
      } else {
         this.j = null;
         if (this.n) {
            this.h = this.a.a(var2);
            if (this.h) {
               this.r = var1;
               this.s = this.a.j();
            }
         } else if (this.o) {
            this.h = this.a.a(var1);
            if (this.h) {
               this.r = this.a.i();
               this.s = var2;
            }
         } else {
            this.h = this.a.b(var1, var2);
            if (this.h) {
               this.r = this.a.i();
               this.s = this.a.j();
            }
         }

         this.f = this.h;
         if (this.p) {
            this.i = this.b.a(var2);
            if (this.i) {
               this.d(var1);
            } else if (this.r > var1) {
               this.b.f();
               this.i = this.b.g();
               this.d(this.r);
            } else {
               this.g = false;
               if (!this.f) {
                  return false;
               }
            }
         } else if (this.q) {
            this.i = this.b.a(var1);
            if (this.i) {
               this.e(var2);
            } else {
               this.g = false;
               if (!this.f) {
                  return false;
               }
            }
         } else if (this.b.b(var1, var2)) {
            this.i = true;
            this.C();
         } else {
            this.i = false;
            this.g = false;
            if (!this.f) {
               return false;
            }
         }

         return true;
      }
   }

   private void d(int var1) {
      if (this.f) {
         if (this.r > var1) {
            this.f = false;
            this.g = true;
            this.r = var1;
            this.s = this.b.j();
         } else {
            int var2 = this.b.j();
            if (var2 == this.s) {
               this.g = true;
            } else if (var2 < this.s) {
               this.f = false;
               this.g = true;
               this.s = var2;
            } else {
               this.g = false;
            }
         }
      } else {
         this.g = true;
         this.r = var1;
         this.s = this.b.j();
      }

   }

   private void e(int var1) {
      if (this.f) {
         int var2 = this.b.i();
         if (var2 == this.r) {
            this.g = true;
            if (this.s > var1) {
               this.f = false;
               this.s = var1;
            }
         } else if (var2 < this.r) {
            this.g = true;
            this.f = false;
            this.r = var2;
            this.s = var1;
         } else {
            this.g = false;
         }
      } else {
         this.g = true;
         this.r = this.b.i();
         this.s = var1;
      }

   }

   private void C() {
      if (this.f) {
         int var1 = this.b.i();
         if (var1 == this.r) {
            int var2 = this.b.j();
            if (var2 == this.s) {
               this.g = true;
            } else if (var2 < this.s) {
               this.g = true;
               this.f = false;
               this.s = var2;
            } else {
               this.g = false;
            }
         } else if (var1 < this.r) {
            this.f = false;
            this.g = true;
            this.r = var1;
            this.s = this.b.j();
         } else {
            this.g = false;
         }
      } else {
         this.g = true;
         this.r = this.b.i();
         this.s = this.b.j();
      }

   }

   public boolean a(int var1) {
      this.j = null;
      return this.b(var1 / this.l, var1 % this.l);
   }

   public void f() {
      super.f();
      this.r = -1;
      this.s = this.m;
   }

   public boolean g() {
      if (!this.k) {
         this.j = null;
         int var1 = this.s + 1;
         int var2;
         if (var1 >= this.m) {
            var2 = this.r + 1;
            if (var2 >= this.l) {
               return false;
            }

            var1 = 0;
            if (this.n) {
               this.a.f();
               this.h = this.a.g();
               this.f = false;
               if (this.q) {
                  if (this.g) {
                     if (this.b.g()) {
                        this.i = true;
                        this.g = this.b.i() == var2;
                     } else {
                        this.i = false;
                        this.g = false;
                     }
                  } else if (this.i) {
                     this.g = this.b.i() == var2;
                  }
               }
            } else if (this.o) {
               if (this.f) {
                  if (this.a.g()) {
                     this.h = true;
                     this.f = this.a.i() == var2;
                  } else {
                     this.h = false;
                     this.f = false;
                  }
               } else if (this.h) {
                  this.f = this.a.i() == var2;
               }

               if (this.p) {
                  this.b.f();
                  this.i = this.b.g();
                  this.g = false;
               }
            } else if (this.q) {
               if (this.g) {
                  if (this.b.g()) {
                     this.i = true;
                     this.g = this.b.i() == var2;
                  } else {
                     this.i = false;
                     this.g = false;
                  }
               } else if (this.i) {
                  this.g = this.b.i() == var2;
               }
            } else if (this.p) {
               this.b.f();
               this.i = this.b.g();
               this.g = false;
            }
         } else {
            var2 = this.r;
         }

         this.r = this.l;
         this.s = this.m;
         if (this.f) {
            if (this.n) {
               if (this.a.g()) {
                  this.f = true;
                  this.r = var2;
                  this.s = this.a.j();
               } else {
                  if (!this.i) {
                     return false;
                  }

                  if (this.q && !this.g) {
                     this.g = true;
                     this.r = this.b.i();
                     this.s = 0;
                     this.a.f();
                     if (this.a.g()) {
                        this.h = true;
                        this.f = this.a.j() == 0;
                     } else {
                        this.h = false;
                        this.f = false;
                     }

                     return true;
                  }

                  this.h = false;
               }
            } else if (this.o) {
               this.r = var2;
               this.s = var1;
            } else if (this.a.g()) {
               this.h = true;
               this.f = true;
               this.r = this.a.i();
               this.s = this.a.j();
            } else {
               if (!this.i) {
                  return false;
               }

               this.h = false;
               this.f = false;
            }
         } else if (this.h) {
            this.f = true;
            if (this.n) {
               this.r = var2;
               this.s = this.a.j();
            } else {
               this.r = this.a.i();
               if (this.o) {
                  this.s = 0;
               } else {
                  this.s = this.a.j();
               }
            }
         }

         if (this.g) {
            if (this.p) {
               if (this.b.g()) {
                  this.d(var2);
               } else if (this.r > var2) {
                  this.b.f();
                  if (this.b.g()) {
                     this.d(this.r);
                  } else {
                     if (!this.h) {
                        return false;
                     }

                     this.i = false;
                     this.g = false;
                  }
               } else {
                  if (!this.h) {
                     return false;
                  }

                  this.i = false;
                  this.g = false;
               }
            } else if (this.q) {
               if (this.f) {
                  if (this.r > var2) {
                     this.f = false;
                     this.r = var2;
                     this.s = var1;
                  } else if (this.s > var1) {
                     this.f = false;
                     this.s = var1;
                  }
               } else {
                  this.r = var2;
                  this.s = var1;
               }
            } else if (this.b.g()) {
               this.i = true;
               this.C();
            } else {
               if (!this.h) {
                  return false;
               }

               this.i = false;
               this.g = false;
            }
         } else if (this.i) {
            if (this.p) {
               this.d(this.r);
            } else if (this.q) {
               this.e(this.s);
            } else {
               this.C();
            }
         } else if (!this.h) {
            return false;
         }

         return true;
      } else {
         this.k = false;
         if (this.f) {
            if (this.p) {
               if (this.i) {
                  return this.b(this.r, this.b.j());
               } else {
                  ++this.r;
                  if (this.r < this.l) {
                     this.b.f();
                     if (this.b.g()) {
                        return this.b(this.r, this.b.j());
                     }
                  }

                  return false;
               }
            } else if (this.q) {
               return this.i && this.b(this.b.i(), 0);
            } else {
               return this.i && this.b(this.b.i(), this.b.j());
            }
         } else if (this.n) {
            if (this.h) {
               return this.b(this.r, this.a.j());
            } else {
               ++this.r;
               if (this.r < this.l) {
                  this.a.f();
                  if (this.a.g()) {
                     return this.b(this.r, this.a.j());
                  }
               }

               return false;
            }
         } else if (this.o) {
            return this.h && this.b(this.a.i(), 0);
         } else {
            return this.h && this.b(this.a.i(), this.a.j());
         }
      }
   }

   public zahn b(int var1) {
      return (zahn)(!this.a.n() && !this.b.n() ? new zawx(this.a.b(var1), this.b.b(var1), this.c, this.d) : new zaxf(this, this.d, var1));
   }

   public zahn c(int var1) {
      return (zahn)(!this.a.m() && !this.b.m() ? new zawx(this.a.c(var1), this.b.c(var1), this.c, this.d) : new zaxe(this, this.d, var1));
   }

   public zahn c(zaay var1) {
      zbvm var2 = new zbvm(this, this.e, this.r(), this.t(), this.s(), this.u(), this.a.c(), this.a.d());
      return new zawy(new zaww(this, var1), var2, var1);
   }

   public int i() {
      return this.r;
   }

   public int j() {
      return this.s;
   }

   public int k() {
      return this.r * this.m + this.s;
   }

   public boolean m() {
      return this.n && this.p;
   }

   public boolean n() {
      return this.o && this.q;
   }

   public int c() {
      return this.l;
   }

   public int d() {
      return this.m;
   }

   public int e() {
      return this.l * this.m;
   }

   public boolean q() {
      return this.a.q() && this.b.q();
   }

   public int r() {
      return !this.n && !this.p ? Math.min(this.a.r(), this.b.r()) : 0;
   }

   public int s() {
      return !this.n && !this.p ? Math.min(this.a.s(), this.b.s()) : this.l - 1;
   }

   public int t() {
      return !this.o && !this.q ? Math.min(this.a.t(), this.b.t()) : 0;
   }

   public int u() {
      return !this.o && !this.q ? Math.max(this.a.u(), this.b.u()) : this.m - 1;
   }

   public int v() {
      if (this.n) {
         return this.q ? 0 : Math.min(this.a.t(), this.b.t());
      } else if (this.p) {
         return this.o ? 0 : Math.min(this.a.t(), this.b.t());
      } else {
         return !this.o && !this.q ? Math.min(this.a.v(), this.b.v()) : Math.min(this.a.r(), this.b.r()) * this.m;
      }
   }

   public int w() {
      if (this.n) {
         return this.q ? 0 : (this.l - 1) * this.m + Math.max(this.a.u(), this.b.u());
      } else if (this.p) {
         return this.o ? 0 : (this.l - 1) * this.m + Math.max(this.a.u(), this.b.u());
      } else {
         return !this.o && !this.q ? Math.max(this.a.w(), this.b.w()) : Math.max(this.a.s(), this.b.s()) * this.m + this.m - 1;
      }
   }
}
